/**
 * Title:
 * Description:
 * @author jjtEatJava
 * @date 2017年7月29日
 */
package com.kiki.jjt.freemark;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;


/**
 * Title:
 * Description:
 * @author jjtEatJava
 * @date 2017年7月29日
 */
public class Dao {
	 	private static String driver = "com.mysql.jdbc.Driver";
	    private static String url = "jdbc:mysql://rm-wz9cmemnh0sfcc8y6o.mysql.rds.aliyuncs.com:3306/bingo_qa?useSSL=true";
	    private static String username = "jiangjt";
	    private static String password = "bingostar";
	    
	    public static void init() throws ClassNotFoundException {
	    	Class.forName(driver);
	    }
	    
	    public static List<String> getAllTableName() throws SQLException{
	    	String sql  = "show tables;";
	    	Connection conn = DriverManager.getConnection(url,username,password);
	    	Statement statement = conn.createStatement();
	    	ResultSet set = statement.executeQuery(sql);
	    	List<String> list = new ArrayList<String>();
	    	while (set.next()) {
				String name = set.getString(1);
				list.add(name);
			}
	    	statement.close();
	    	conn.close();
	    	return list;
	    }
}
